<?php
/**
 *订单列表
 */
session_start();
require ('conn.php');
$sel='select * from orderinfo order by Id';
$query=mysqli_query($conn,$sel);

if (isset($_SESSION['username'])){
    ?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>订单列表</title>
</head>
<body>
<div style="width: 800px;margin: auto">
    <h1>订单列表</h1>
    <a href="order.php?id=$"><input type="button" value="在线订药"></a>
    <hr>
    <table border="1px solid">
        <tr>
            <td>编号</td>
            <td>药名</td>
            <td>下单人</td>
            <td>下单时间</td>
            <td>收货人</td>
            <td>收件人电话</td>
            <td>收货地址</td>
            <td>配送方式</td>
            <td>状态</td>
            <td>配送时间</td>
            <td>备注</td>

        </tr>
        <?php
        while($row=mysqli_fetch_assoc($query)){
            $UserId=$row['UserId'];
        $username="select username from userinfo where UserId=$UserId";
        $username=mysqli_query($conn,$username);
        $username=mysqli_fetch_assoc($username);
        $username=implode(',',$username);

        ?>

        <tr>
            <td><?php echo $row['Id']?></td>
            <td><?php echo $row['MedicineName']?></td>
            <td><?php echo $username?></td>
            <td><?php echo $row['AddTime']?></td>
            <td><?php echo $row['RealName']?></td>
            <td><?php echo $row['Mobile']?></td>
            <td><?php echo $row['Address']?></td>
            <td><?php if($row['SendType']==0){echo '商家配送';}else{echo '自提';} ?></td>
            <td><?php if ($row['State']==1){echo '未配送';}else{echo '已配送';}?></td>
            <td><?php echo $row['SendTime']?></td>
            <td><?php echo $row['Remark']?></td>
            <?php
            }
            ?>

    </table>
    <hr>
</div>
</body>
</html>
<?php
}
else{
    echo "<script>alert('请先登录！');window.location.href='Login.php';</script>";
}



